<template>
<div class="body">
  <div class="main">
    <img class="duanxin-image" src="../assets/duanxin-bg.jpg" alt="">
    <div class="btn-area">
      <span class="btn-duanxin" @click="openApp"></span>
    </div>
  </div>
</div>
</template>
<script>
const nativeSchema = require("@/config/nativeSchema").nativeSchema
import { getSchemaProtocal, getAppDownload } from '@/config/util'
export default{
  data(){
    return{
            pageName: "短息页" //标题
        }
  },
  components: {},
  mounted () {},
  methods:{
    openApp() {
      const u = window.navigator.userAgent;
            const isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
            const isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
            if(isAndroid){
                nativeSchema.loadSchema({
                    // 通过NN打开某个链接
                    schema: "",
                    //schema头协议，实际情况填写
                    protocal: getSchemaProtocal(),
                    //发起唤醒请求后，会等待loadWaiting时间，超时则跳转到failUrl，默认3000ms
                    loadWaiting:"3000",
                    //唤起失败时的跳转链接，默认跳转到下载页
                    failUrl: getAppDownload(),
                    // apk信息,请根据实际情况填写
                    apkInfo:{
                        PKG: "com.ivydad.readtool",
                        // CATEGORY: "android.intent.category.DEFAULT",
                        CATEGORY:"android.intent.category.BROWSABLE",
                        ACTION: "android.intent.action.VIEW"
                    }
                })
            }else if(isiOS){
                window.location.href = getSchemaProtocal()
                setTimeout(() => {
                    window.location.href = getAppDownload()
                },2000)
            }
    }
  }
} 
</script>

<style scoped lang="less">
@import url(../styles/common/common.less);
.body{
  background-color: #00a10f; 
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  background-repeat: repeat;
  background-size: cover;
  background-position: center;
}
.duanxin-image{
  display: block;
  width: 100%;
}
.btn-area{
  text-align: center;
  padding-top: .40rem; /* 80/200 */
  span.btn-duanxin{
    display: inline-block;
    vertical-align: top;
    background-image: url(../assets/btn-duanxin.png);
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    width: 3rem; /* 600/200 */
    height: .70rem; /* 140/200 */
  }
}
</style>